package plantshop.model;
import java.io.Serializable;
import java.util.Iterator;
import java.util.Map;

import plantshop.model.plants.Plant;

public class DisplayIterator implements Iterator<Plant>,Serializable{
	private static final long serialVersionUID = -754328461997890387L;
	Map<Integer, Plant> plants;
	private int index;
	
	public DisplayIterator(Map<Integer, Plant> plants){
		this.plants = plants;
		index = 0;
	}
	
	@Override
	public boolean hasNext() {
		while(index < plants.size() && plants.get(index) == null)
			index++;
		return index < plants.size();
	}

	@Override
	public Plant next() {
		return plants.get(index++);
	}

	@Override
	public void remove() {
		throw new UnsupportedOperationException();
	}

}
